//
//  YZAboutProductHeaderView.m
//  kuaiyi
//
//  Created by 刘邓诏初 on 16/5/5.
//
//

#import "YZAboutProductHeaderView.h"

@interface YZAboutProductHeaderView()
/// 图标
@property(nonatomic,strong)UIImageView *iconView;

@end

@implementation YZAboutProductHeaderView

/// 返回头部view
+ (instancetype)aboutProductHeaderView{
    return [[self alloc] init];
}

// 代码创建
-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self prepareUI];
    }
    return self;
}

// 从xib或sb中创建时调用
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        [self prepareUI];
    }
    return self;
}

- (void)prepareUI{
    // 添加子控件
    [self addSubview:self.iconView];
    
    // 禁用 Autoresizing
    self.iconView.translatesAutoresizingMaskIntoConstraints = NO;
    
    // 添加约束
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.iconView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.iconView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1 constant:60]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.iconView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1 constant:-60]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.iconView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil  attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:self.iconView.bounds.size.height * 0.7]];
    
}

#pragma mark - 懒加载
- (UIImageView *)iconView{
    if (_iconView == nil) {
        _iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Logos"]];
    }
    return _iconView;
}



@end
